package api

import (
	"feishu-alter/model"
	"feishu-alter/notifier"
	"log"
	"net/http"

	"github.com/gin-gonic/gin"
)

func SendMegToFeishu(c *gin.Context) {
	var notification model.Notification
	err := c.ShouldBind(&notification)
	if err != nil {
		c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
		return
	}
	err = notifier.Send(notification)
	if err != nil {
		log.Println(err.Error())
		c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
		return
	}
	c.JSON(http.StatusOK, gin.H{"message": "告警发送成功"})
}

func Health(c *gin.Context) {
	c.JSON(http.StatusOK, gin.H{"status": "ok"})
}
